1
<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" :inline="true">
      <el-form-item label="客户" prop="sys_user_id">
        <el-select
          v-model="queryParams.sys_user_id"
          placeholder="请选择客户"
          filterable
          clearable
        >
          <el-option
            v-for="customer in customerList"
            :key="customer.id"
            :label="customer.username + '(' + customer.nickname + ')'"
            :value="customer.id"
          />
        </el-select>
      </el-form-item>

      <el-form-item label="创建时间">
        <el-date-picker
          ref="datePicker"
          v-model="dateRange"
          style="width: 380px"
          value-format="x"
          type="datetimerange"
          range-separator="-"
          start-placeholder="开始日期"
          end-placeholder="结束日期"
          :default-time="defaultTime"
        ></el-date-picker>
      </el-form-item>
      <el-form-item label="修改时间">
        <el-date-picker
          ref="datePicker"
          v-model="dateRange1"
          style="width: 380px"
          value-format="x"
          type="datetimerange"
          range-separator="-"
          start-placeholder="开始日期"
          end-placeholder="结束日期"
          :default-time="defaultTime"
        ></el-date-picker>
      </el-form-item>
      <el-form-item>
        <el-button
          type="primary"
          icon="Search"
          size="small"
          @click="handleQuery"
          >搜索</el-button
        >
        <el-button icon="Refresh" size="small" @click="resetQuery"
          >重置</el-button
        >
      </el-form-item>
    </el-form>
    <div v-loading="loading">
      <el-row :gutter="40" class="panel-group">
        <el-col :xs="12" :sm="12" :lg="6" class="card-panel-col">
          <div class="card-panel">
            <div class="card-panel-icon-wrapper icon-shopping">
              <svg-icon icon-class="shopping" class-name="card-panel-icon" />
            </div>
            <div class="card-panel-description">
              <div class="card-panel-text">订单总数</div>
              <span class="card-panel-num">{{ statics.total_nums }}</span>
            </div>
          </div>
        </el-col>
        <el-col :xs="12" :sm="12" :lg="6" class="card-panel-col">
          <div class="card-panel">
            <div class="card-panel-icon-wrapper icon-shopping">
              <svg-icon icon-class="shopping" class-name="card-panel-icon" />
            </div>
            <div class="card-panel-description">
              <div class="card-panel-text">完成订单数</div>
              <span class="card-panel-num">{{ statics.success_nums }}</span>
            </div>
          </div>
        </el-col>
        <el-col :xs="12" :sm="12" :lg="6" class="card-panel-col">
          <div class="card-panel">
            <div class="card-panel-icon-wrapper icon-shopping">
              <svg-icon icon-class="shopping" class-name="card-panel-icon" />
            </div>
            <div class="card-panel-description">
              <div class="card-panel-text">待处理订单数</div>
              <span class="card-panel-num">{{ statics.processing_nums }}</span>
            </div>
          </div>
        </el-col>
        <el-col :xs="12" :sm="12" :lg="6" class="card-panel-col">
          <div class="card-panel">
            <div class="card-panel-icon-wrapper icon-shopping">
              <svg-icon icon-class="shopping" class-name="card-panel-icon" />
            </div>
            <div class="card-panel-description">
              <div class="card-panel-text">失败订单数</div>
              <span class="card-panel-num">{{ statics.fail_nums }}</span>
            </div>
          </div>
        </el-col>
      </el-row>

      <el-row :gutter="40" class="panel-group">
        <el-col :xs="12" :sm="12" :lg="6" class="card-panel-col">
          <div class="card-panel">
            <div class="card-panel-icon-wrapper icon-money">
              <svg-icon icon-class="money" class-name="card-panel-icon" />
            </div>
            <div class="card-panel-description">
              <div class="card-panel-text">总交易金额</div>
              <span class="card-panel-num">{{ statics.total_money }}</span>
            </div>
          </div>
        </el-col>
        <el-col :xs="12" :sm="12" :lg="6" class="card-panel-col">
          <div class="card-panel">
            <div class="card-panel-icon-wrapper icon-money">
              <svg-icon icon-class="money" class-name="card-panel-icon" />
            </div>
            <div class="card-panel-description">
              <div class="card-panel-text">完成金额</div>
              <span class="card-panel-num">{{ statics.success_money }}</span>
            </div>
          </div>
        </el-col>
        <el-col :xs="12" :sm="12" :lg="6" class="card-panel-col">
          <div class="card-panel">
            <div class="card-panel-icon-wrapper icon-money">
              <svg-icon icon-class="money" class-name="card-panel-icon" />
            </div>
            <div class="card-panel-description">
              <div class="card-panel-text">待处理金额</div>
              <span class="card-panel-num">{{ statics.processing_money }}</span>
            </div>
          </div>
        </el-col>
        <el-col :xs="12" :sm="12" :lg="6" class="card-panel-col">
          <div class="card-panel">
            <div class="card-panel-icon-wrapper icon-money">
              <svg-icon icon-class="money" class-name="card-panel-icon" />
            </div>
            <div class="card-panel-description">
              <div class="card-panel-text">失败金额</div>
              <span class="card-panel-num">{{ statics.fail_money }}</span>
            </div>
          </div>
        </el-col>
      </el-row>

      <el-row :gutter="40" class="panel-group">
        <!-- <el-col :xs="12" :sm="12" :lg="6" class="card-panel-col">
          <div class="card-panel">
            <div class="card-panel-icon-wrapper icon-money">
              <svg-icon icon-class="money" class-name="card-panel-icon" />
            </div>
            <div class="card-panel-description">
              <div class="card-panel-text">总成本</div>
              <span class="card-panel-num">{{ statics.total_cost }}</span>
            </div>
          </div>
        </el-col>
        <el-col :xs="12" :sm="12" :lg="6" class="card-panel-col">
          <div class="card-panel">
            <div class="card-panel-icon-wrapper icon-money">
              <svg-icon icon-class="money" class-name="card-panel-icon" />
            </div>
            <div class="card-panel-description">
              <div class="card-panel-text">充值完成成本</div>
              <span class="card-panel-num">{{ statics.success_cost }}</span>
            </div>
          </div>
        </el-col> -->
        <el-col :xs="12" :sm="12" :lg="6" class="card-panel-col">
          <div class="card-panel">
            <div class="card-panel-icon-wrapper icon-money">
              <svg-icon icon-class="money" class-name="card-panel-icon" />
            </div>
            <div class="card-panel-description">
              <div class="card-panel-text">佣金</div>
              <span class="card-panel-num">{{ statics.profit }}</span>
            </div>
          </div>
        </el-col>
        <el-col :xs="12" :sm="12" :lg="6" class="card-panel-col">
          <div class="card-panel">
            <div class="card-panel-icon-wrapper icon-money">
              <svg-icon icon-class="money" class-name="card-panel-icon" />
            </div>
            <div class="card-panel-description">
              <div class="card-panel-text">退款总金额</div>
              <span class="card-panel-num">{{ statics.refund_money }}</span>
            </div>
          </div>
        </el-col>
      </el-row>
    </div>
  </div>
</template>

<script>
// import { getArea as getAreas } from "@/api/common";
// import { getListAll as listAllCzProduct } from "@/api/platform/czProductSpec";
import { getAllList as listAllCustomer } from "@/api/platform/merchant";
import { getStatics } from "@/api/platform/moviesOrder";
// import { getAllList as listAllChannel } from "@/api/channel";

export default {
  name: "platformmoviesCensusindex",
  //   dicts: ["cz_product_type", "cz_isp"],
  data() {
    return {
      // 遮罩层
      loading: false,
      productList: [],
      // 省份列表
      provinceList: [],
      customerList: [],
      // 省份列表
      cityList: [],
      // 字典表格数据
      statics: {
        total_nums: 0,
        success_nums: 0,
        processing_nums: 0,
        fail_nums: 0,

        total_money: 0,
        success_money: 0,
        processing_money: 0,
        fail_money: 0,

        total_cost: 0,
        success_cost: 0,
        profit: 0,
      },
      // 日期范围
      // dateRange: this.getTimeFilterDefault(true),
      dateRange: [
        new Date(new Date().setHours(0, 0, 0, 0)).getTime(),
        new Date().getTime(),
      ],
      dateRange1: [],
      // 查询参数
      queryParams: {
        spec_id: undefined,
        recharge_type: undefined,
        isp: undefined,
        province_id: undefined,
        city_id: undefined,
        face_value: undefined,
        sys_user_id: undefined,
        channel_id: undefined,
      },
      channelList: [],
    };
  },
  created() {
    this.getCustomerList();
    // this.getProvinceList();
    // this.getAllProductList();
    // this.getChannelList();
    this.getStatics();
  },
  computed: {
    defaultTime() {
      return [new Date(2000, 1, 1, 0, 0, 0), new Date(2000, 1, 1, 23, 59, 59)];
      //   const myDate = new Date();
      //   const hours = myDate.getHours();
      //   const min = myDate.getMinutes();
      //   const second = myDate.getSeconds();
      //   const endTime =
      //     String(hours).padStart(2, "0") +
      //     ":" +
      //     String(min).padStart(2, "0") +
      //     ":" +
      //     String(second).padStart(2, "0");
      //   return ["00:00:00", endTime];
    },
  },
  methods: {
    getStatics() {
      console.log(this.dateRange1);
      const res = this.addDateRange({}, this.dateRange1);
      console.log(111, res);
      this.queryParams.updated_at = res.params;
      this.loading = true;
      const obj = this.addDateRange(this.queryParams, this.dateRange);
      obj.created_at = [obj.params.beginTime, obj.params.endTime];
      delete obj.params;
      getStatics(obj).then((response) => {
        this.statics = response.data;
        this.loading = false;
      });
    },
    getCustomerList() {
      listAllCustomer().then((response) => {
        this.customerList = response.data;
      });
    },
    getProvinceList() {
      getAreas({ level_type: 1 }).then((response) => {
        this.provinceList = response.data;
      });
    },
    getCityList(id) {
      getAreas({ level_type: 2, parent_id: id }).then((response) => {
        this.cityList = response.data;
      });
    },
    handleProvinceChange(val) {
      if (val) {
        this.getCityList(val);
      }
    },
    handleProvinceClear() {
      this.queryParams.city_id = undefined;
      this.cityList = [];
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.page = 1;
      this.getStatics();
    },
    /** 重置按钮操作 */
    resetQuery() {
      // this.dateRange = this.getTimeFilterDefault(true);
      this.dateRange = [
        new Date(new Date().setHours(0, 0, 0, 0)).getTime(),
        new Date().getTime(),
      ];
      // console.log(this.dateRange);
      // console.log([
      //   new Date(new Date().setHours(0, 0, 0, 0)).getTime(),
      //   new Date().getTime(),
      // ]);
      this.resetForm("queryForm");
      this.handleQuery();
    },
  },
};
</script>

<style lang="scss" scoped>
.panel-group {
  margin-top: 18px;

  .card-panel-col {
    margin-bottom: 32px;
  }

  .card-panel {
    height: 108px;
    cursor: pointer;
    font-size: 12px;
    position: relative;
    overflow: hidden;
    color: #666;
    background: #fff;
    box-shadow: 4px 4px 40px rgba(0, 0, 0, 0.05);
    border-color: rgba(0, 0, 0, 0.05);

    &:hover {
      .card-panel-icon-wrapper {
        color: #fff;
      }

      .icon-people {
        background: #40c9c6;
      }

      .icon-message {
        background: #36a3f7;
      }

      .icon-money {
        background: #f4516c;
      }

      .icon-shopping {
        background: #34bfa3;
      }
    }

    .icon-people {
      color: #40c9c6;
    }

    .icon-message {
      color: #36a3f7;
    }

    .icon-money {
      color: #f4516c;
    }

    .icon-shopping {
      color: #34bfa3;
    }

    .card-panel-icon-wrapper {
      float: left;
      margin: 14px 0 0 14px;
      padding: 16px;
      transition: all 0.38s ease-out;
      border-radius: 6px;
    }

    .card-panel-icon {
      float: left;
      font-size: 48px;
    }

    .card-panel-description {
      float: right;
      font-weight: bold;
      margin: 26px;
      margin-left: 0px;

      .card-panel-text {
        line-height: 18px;
        color: rgba(0, 0, 0, 0.45);
        font-size: 16px;
        margin-bottom: 12px;
      }

      .card-panel-num {
        font-size: 20px;
      }
    }
  }
}

@media (max-width: 550px) {
  .card-panel-description {
    display: none;
  }

  .card-panel-icon-wrapper {
    float: none !important;
    width: 100%;
    height: 100%;
    margin: 0 !important;

    .svg-icon {
      display: block;
      margin: 14px auto !important;
      float: none !important;
    }
  }
}
</style>
